<?php if(isset($claim) && $claim == true){ ?>
<script>
$(document).ready(function(){
        $("#ListingClaimForm").submit(function(){
               if($.trim($("#ListingName").val()) == ""){
                   alert('Name field must not be empty.');
return false;
               } else if($.trim($("#ListingTelephone").val()) == ""){
                    alert('Telephone must not empty');
return false;
               }


         });
});
</script>
<div class="listings form">
    <?php
    echo $this->Form->create(
            'Listing', array(
        'type' => 'post',
        'url' => array(
            'admin' => false,
            'plugin' => null,
            'controller' => 'listings',
            'action' => 'submit',
              $listing,
              'claim'
        )
            )
    );
    ?>
    <fieldset>
           <legend>Please Fill Up the following form.</legend>
        <?php
                echo $this->Form->input('name', array('label'=>'Name', 'value'=>''));

        echo $this->Form->input(
                'telephone', array('label'=>'Telephone', 'value'=>''));

 echo $this->Form->input(
                'comment', array('label'=>'Comment', 'value'=>'', 'type'=>'textarea'));

        ?>
    </fieldset>
        <?php
        echo $this->Form->end(
                array(
                    'label' => 'Claim',
                    'id' => 'submitClaim'
                )
        );
        ?>
</div>

<?php } else { ?>
<script type="text/javascript">
$(window).load(function(){
$("#ListingLocationId option:selected").trigger("change");
	$("#ListingCategoryId option:selected").trigger("change");
});



   var map;
    var input;
    var autocomplete;
    var marker;
    function initialize() {

        var mapOptions = {
            center: new google.maps.LatLng(-34.397, 150.644),
            zoom: 8,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
     map= new google.maps.Map(document.getElementById("map_canvas2"),
        mapOptions);


    }
    google.maps.event.addDomListener(window, 'load', initialize);
     function callback(results, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) {
            TrainStations='';
            BusStops='';
            SubWays='';
            var ts,ss,bs,limit;
            ts=0;
            bs=0;
            ss=0;
            limit=3;
            for (var i = 0; i < results.length; i++) {
 //sortresults(results[i]);
                for (var j=0 ; j<results[i].types.length;j++){
                    if (results[i].types[j]=='train_station' && ts<limit){
                        TrainStations=TrainStations+results[i].name + ' - ' + getDistanceFromLatLonInKm(marker.position.lat(),marker.position.lng(),results[i].geometry.location.lat(),results[i].geometry.location.lng()) +' km <br/>';
                        ts++;
                    }
                    else if(results[i].types[j]=='bus_station' && bs<limit){
                        BusStops=BusStops+results[i].name + ' - ' + getDistanceFromLatLonInKm(marker.position.lat(),marker.position.lng(),results[i].geometry.location.lat(),results[i].geometry.location.lng()) +' km <br/>';
                        bs++;
                    }
                    else if(results[i].types[j]=='subway_station' && ss<limit){
                        SubWays=SubWays+results[i].name + ' - ' + getDistanceFromLatLonInKm(marker.position.lat(),marker.position.lng(),results[i].geometry.location.lat(),results[i].geometry.location.lng()) +' km <br/>';
                        ss++;
                    }
                }
            }
            document.getElementById('train_stations').value=TrainStations;
        }
    }
    function callback2(results, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) {
            TrainStations='';
            BusStops='';
            SubWays='';
            var ts,ss,bs,limit;
            ts=0;
            bs=0;
            ss=0;
            limit=3;
            for (var i = 0; i < results.length; i++) {
 //sortresults(results[i]);
                for (var j=0 ; j<results[i].types.length;j++){
                    if (results[i].types[j]=='train_station' && ts<limit){
                        TrainStations=TrainStations+results[i].name + ' - ' + getDistanceFromLatLonInKm(marker.position.lat(),marker.position.lng(),results[i].geometry.location.lat(),results[i].geometry.location.lng()) +' km <br/>';
                        ts++;
                    }
                    else if(results[i].types[j]=='bus_station' && bs<limit){
                        BusStops=BusStops+results[i].name + ' - ' + getDistanceFromLatLonInKm(marker.position.lat(),marker.position.lng(),results[i].geometry.location.lat(),results[i].geometry.location.lng()) +' km <br/>';
                        bs++;
                    }
                    else if(results[i].types[j]=='subway_station' && ss<limit){
                        SubWays=SubWays+results[i].name + ' - ' + getDistanceFromLatLonInKm(marker.position.lat(),marker.position.lng(),results[i].geometry.location.lat(),results[i].geometry.location.lng()) +' km <br/>';
                        ss++;
                    }
                }
            }
            document.getElementById('bus_stations').value=BusStops;
        }
    }
    function callback3(results, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) {
            TrainStations='';
            BusStops='';
            SubWays='';
            var ts,ss,bs,limit;
            ts=0;
            bs=0;
            ss=0;
            limit=3;
            for (var i = 0; i < results.length; i++) {
             //   sortresults(results[i]);
                for (var j=0 ; j<results[i].types.length;j++){
                    if (results[i].types[j]=='train_station' && ts<limit){
                        TrainStations=TrainStations+results[i].name + ' - ' + getDistanceFromLatLonInKm(marker.position.lat(),marker.position.lng(),results[i].geometry.location.lat(),results[i].geometry.location.lng()) +' km <br/>';
                        ts++;
                    }
                    else if(results[i].types[j]=='bus_station' && bs<limit){
                        BusStops=BusStops+results[i].name + ' - ' + getDistanceFromLatLonInKm(marker.position.lat(),marker.position.lng(),results[i].geometry.location.lat(),results[i].geometry.location.lng()) +' km <br/>';
                        bs++;
                    }
                    else if(results[i].types[j]=='subway_station' && ss<limit){
                        SubWays=SubWays+results[i].name + ' - ' + getDistanceFromLatLonInKm(marker.position.lat(),marker.position.lng(),results[i].geometry.location.lat(),results[i].geometry.location.lng()) +' km <br/>';
                        ss++;
                    }
                }
            }
            document.getElementById('subway_stations').value=SubWays;
        }
    }
    var marker;
    function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
        var R = 6371; // Radius of the earth in km
        var dLat = deg2rad(lat2-lat1);  // deg2rad below
        var dLon = deg2rad(lon2-lon1);
        var a =
            Math.sin(dLat/2) * Math.sin(dLat/2) +
            Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
            Math.sin(dLon/2) * Math.sin(dLon/2)
        ;
        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
        var d = R * c; // Distance in km
        return Math.round(d*100)/100;
    }

    function deg2rad(deg) {
        return deg * (Math.PI/180)
    }
    function findonmap() {
         marker = new google.maps.Marker({
                    map: map      });

          var geocoder = new google.maps.Geocoder();

        var start = document.getElementById("ListingAddress1").value;


                geocoder.geocode( { 'address': start}, function(results2, status) {
                    setTimeout('', 500);
                    if (status == google.maps.GeocoderStatus.OK) {
                        marker.setVisible(false);
                        map.setZoom(14);
                        map.setCenter(results2[0].geometry.location);
                        marker.setPosition(results2[0].geometry.location);
                        marker.setVisible(true);
                         var request = {
                            location: marker.position,
                            types: ['train_station'],
                            radius:7000

                        };

                        service = new google.maps.places.PlacesService(map);
                        service.nearbySearch(request, callback);
                        request = {
                            location: marker.position,
                            types: ['bus_station'],
                            radius:7000

                        };

                        service = new google.maps.places.PlacesService(map);
                        service.nearbySearch(request, callback2);
                        request = {
                            location: marker.position,
                            types: ['subway_station'],
                            radius:7000
                           // rankBy: google.maps.places.RankBy.DISTANCE

                        };

                        service = new google.maps.places.PlacesService(map);
                        service.nearbySearch(request, callback3);

                    } else {
                        alert("Geocode was not successful for the following reason: " + status);
                    }
                });
       }

    $(function() {

	loadLevelOneCategories(<?php echo $this->data['Listing']['category_id']; ?>);


        $("#ListingLocationId").change(function(event){
            loadLevelOneLocations($(this).val());
        });



        $("#ListingCategoryId").change(function(event) {
            loadLevelOneCategories($(this).val());
        });



        $("#levelOneCategories").live("change", function() {
            loadLevelTwoCategories($(this).val());
        });

        $("#levelTwoCategories").live("change", function() {
            loadLevelThreeCategories($(this).val());
        });

        $("#levelThreeCategories").live("change", function() {
            loadLevelFourCategories($(this).val());
        });



        $("#levelFourCategories").live("change", function() {
            loadLevelInfinityCategories($(this).val());
        });


        $("#btn__add___Submit").click(function(event) {
            // clear all old errors
            $("#ListingLocationId").removeClass("form-error");
            $("#ListingLocationIdJsErrorMsg1").css("display", "none");

            $("#ListingCategoryId").removeClass("form-error");
            $("#ListingCategoryIdJsErrorMsg1").css("display", "none");

            $("#levelOneCategories").removeClass("form-error");
            $("#levelOneCategoriesJsErrorMsg1").css("display", "none");

            $("#levelTwoCategories").removeClass("form-error");
            $("#levelTwoCategoriesJsErrorMsg1").css("display", "none");

            $("#levelThreeCategories").removeClass("form-error");
            $("#levelThreeCategoriesJsErrorMsg1").css("display", "none");

            $("#levelFourCategories").removeClass("form-error");
            $("#levelFourCategoriesJsErrorMsg1").css("display", "none");

            $("#levelNCategories").removeClass("form-error");
            $("#levelNCategoriesJsErrorMsg1").css("display", "none");

            $("#ListingTitle").removeClass("form-error");
            $("#ListingTitleJsErrorMsg1").css("display", "none");

            $("#ListingDescription").removeClass("form-error");
            $("#ListingDescriptionJsErrorMsg1").css("display", "none");
            $("#ListingDescriptionJsErrorMsg2").css("display", "none");

            isError = false;

            // check for new errors
            if ($("#ListingLocationId").length) {
                if ($("#ListingLocationId").val() == '') {
                    event.preventDefault();
                    $("#ListingLocationId").addClass("form-error");
                    $("#ListingLocationIdJsErrorMsg1").css("display", "block");
                    isError = true;
                }
            }

            if ($("#ListingCategoryId").length) {
                if ($("#ListingCategoryId").val() == '') {
                    event.preventDefault();
                    $("#ListingCategoryId").addClass("form-error");
                    $("#ListingCategoryIdJsErrorMsg1").css("display", "block");
                    isError = true;
                }
            }
            if ($("#levelOneCategories").length) {
                if ($("#levelOneCategories").val() == '') {
                    event.preventDefault();
                    $("#levelOneCategories").addClass("form-error");
                    $("#levelOneCategoriesJsErrorMsg1").css("display", "block");
                    isError = true
                }
            }
            if ($("#levelTwoCategories").length) {
                if ($("#levelTwoCategories").val() == '') {
                    event.preventDefault();
                    $("#levelTwoCategories").addClass("form-error");
                    $("#levelTwoCategoriesJsErrorMsg1").css("display", "block");
                    isError = true;
                }
            }
            if ($("#levelThreeCategories").length) {
                if ($("#levelThreeCategories").val() == '') {
                    event.preventDefault();
                    $("#levelThreeCategories").addClass("form-error");
                    $("#levelThreeCategoriesJsErrorMsg1").css("display", "block");
                    isError = true;
                }
            }
            if ($("#levelFourCategories").length) {
                if ($("#levelFourCategories").val() == '') {
                    event.preventDefault();
                    $("#levelFourCategories").addClass("form-error");
                    $("#levelFourCategoriesJsErrorMsg1").css("display", "block");
                    isError = true;
                }
            }
            if ($("#levelNCategories").length) {
                if ($("#levelNCategories").val() == '') {
                    event.preventDefault();
                    $("#levelNCategories").addClass("form-error");
                    $("#levelNCategoriesJsErrorMsg1").css("display", "block");
                    isError = true;
                }
            }

            if ($("#ListingTitle").length) {
                if ($("#ListingTitle").val() == '') {
                    event.preventDefault();
                    $("#ListingTitle").addClass("form-error");
                    $("#ListingTitleJsErrorMsg1").css("display", "block");
                    isError = true;
                }
            }

            if ($("#ListingDescription").length) {
                if ($("#ListingDescription").val() == '') {
                    event.preventDefault();
                    $("#ListingDescription").addClass("form-error");
                    $("#ListingDescriptionJsErrorMsg1").css("display", "block");
                    isError = true;
                }

                if ($("#ListingDescription").val().length < 120) {
                    event.preventDefault();
                    $("#ListingDescription").addClass("form-error");
                    $("#ListingDescriptionJsErrorMsg2").css("display", "block");
                    isError = true;
                }
            }

            if (isError) {
                window.location.replace("#");
            }
        });
    });

            function loadLevelOneLocations(parent){
            if (parent == ""){
                clearLevelOneLocations();
            }
            else{
                //alert("<?php echo SITE_WEBROOT; ?>listings/submit_getsublocations/"+parent);
                $.get("<?php echo SITE_WEBROOT; ?>listings/submit_getsublocations/"+parent, function(data){
                    if (data == ""){
                        clearLevelOneLocations();
                    }
                    else {
                        $("#ListingLocationId").attr("name", "data[Listing][level0_location]");
                        $("#levelOneLocationsDiv").html(data);
                    }
                });
            }
        }
        function clearLevelOneLocations(){
            $("#ListingLocationId").attr("name", "data[Listing][location_id]");
            $("#levelOneLocationsDiv").html("");
        }

                function loadLevelOneCategories(parent) {
            if (parent == "") {
                clearLevelOneCategories();
            } else {
                $.get("<?php echo SITE_WEBROOT; ?>listings/submit_getfirstchildcategories/"+parent+"/levelOneCategories", function(data) {
                    if(data == "") {
                        clearLevelOneCategories();
                    } else {
                        $("#ListingCategoryId").attr("name", "data[Listing][levelzero_category]");
                        $("#levelOneCategoriesDiv").html(data);
                    }
                });
            }
        }
        function clearLevelOneCategories() {
            $("#ListingCategoryId").attr("name", "data[Listing][category_id]");
            $("#levelOneCategoriesDiv").html("");
            $("#levelTwoCategoriesDiv").html("");
            $("#levelThreeCategoriesDiv").html("");
            $("#levelFourCategoriesDiv").html("");
            $("#levelInfinityCategoriesDiv").html("");
        }

         function loadLevelTwoCategories(parent) {
            if (parent == "") {
                clearLevelTwoCategories();
            } else {
                $.get("<?php echo SITE_WEBROOT; ?>listings/submit_getfirstchildcategories/"+parent+"/levelTwoCategories", function(data) {
                    if(data == "") {
                        clearLevelTwoCategories();
                    } else {
                        $("#levelOneCategories").attr("name", "data[Listing][levelone_category]");
                        $("#levelTwoCategoriesDiv").html(data);
                    }
                });
            }
        }
        function clearLevelTwoCategories() {
            $("#levelOneCategories").attr("name", "data[Listing][category_id]");
            $("#levelTwoCategoriesDiv").html("");
            $("#levelThreeCategoriesDiv").html("");
            $("#levelFourCategoriesDiv").html("");
            $("#levelInfinityCategoriesDiv").html("");
        }

 function loadLevelThreeCategories(parent) {
            if (parent == "") {
                clearLevelThreeCategories();
            } else {
                $.get("<?php echo SITE_WEBROOT; ?>listings/submit_getfirstchildcategories/"+parent+"/levelThreeCategories", function(data) {
                    if(data == "") {
                        clearLevelThreeCategories();
                    } else {
                        $("#levelTwoCategories").attr("name", "data[Listing][leveltwo_category]");
                        $("#levelThreeCategoriesDiv").html(data);
                    }
                });
            }
        }
        function clearLevelThreeCategories() {
            $("#levelTwoCategories").attr("name", "data[Listing][category_id]");
            $("#levelThreeCategoriesDiv").html("");
            $("#levelFourCategoriesDiv").html("");
            $("#levelInfinityCategoriesDiv").html("");
        }

 function loadLevelFourCategories(parent) {
            if (parent == "") {
                clearLevelFourCategories();
            } else {
                $.get("<?php echo SITE_WEBROOT; ?>listings/submit_getfirstchildcategories/"+parent+"/levelFourCategories", function(data) {
                    if(data == "") {
                        clearLevelFourCategories();
                    } else {
                        $("#levelThreeCategories").attr("name", "data[Listing][levelthree_category]");
                        $("#levelFourCategoriesDiv").html(data);
                    }
                });
            }
        }
        function clearLevelFourCategories() {
            $("#levelThreeCategories").attr("name", "data[Listing][category_id]");
            $("#levelFourCategoriesDiv").html("");
            $("#levelInfinityCategoriesDiv").html("");
        }
   function loadLevelInfinityCategories(parent) {
            $.get("<?php echo SITE_WEBROOT; ?>listings/submit_getsubcategories/"+parent, function(data) {
                if(data == "") {
                    $("#levelThreeCategories").attr("name", "data[Listing][category_id]");
                    $("#levelInfinityCategoriesDiv").html("");
                } else {
                    $("#levelFourCategories").attr("name", "data[Listing][levelfour_category]");
                    $("#levelInfinityCategoriesDiv").html(data);
                }
            });
        }
</script>

<div class="listings form">
    <?php
    echo $this->Form->create(
            'Listing', array(
        'type' => 'post',
        'enctype' => 'multipart/form-data',
        'url' => array(
            'admin' => false,
            'plugin' => null,
            'controller' => 'listings',
            'action' => 'submit'
        )
            )
    );
    ?>
    <fieldset>
        <legend><?php echo 'Безплатно добавяне на сайт'; ?></legend>
        <?php
               	echo $this->Form->input('id', array('value'=>$this->data['Listing']['id']));
        echo $this->Form->input(
                'location_id', array(
            'label' => 'Location',
            'default' => $this->data['Listing']['location_id'],
            'error' => false
                )
        );

        echo $this->Form->error(
                'location_id', array(
            'LocationRule1' => 'Не сте избрали населено място'
                ), array(
            'wrap' => 'div',
            'class' => 'error-message'
                )
        );
        echo '<div id="ListingLocationIdJsErrorMsg1" style="display:none;" class="error-message">Не сте избрали населено място</div>';

        echo '<div id="levelOneLocationsDiv" style="padding: 0; margin: 0;"></div>';
        echo '<div id="levelOneLocationsJsErrorMsg1" style="display:none;" class="error-message">Моля изберете субкатегория</div>';


        echo $this->Form->input(
                'category_id', array(
            'label' => 'Select Category',
            'default' => $this->data['Listing']['category_id'],
            'error' => false
                )
        );
        echo $this->Form->error(
                'category_id', array(
            'CategoryRule1' => 'Моля изберете категория'
                ), array(
            'wrap' => 'div',
            'class' => 'error-message'
                )
        );
        echo '<div id="ListingCategoryIdJsErrorMsg1" style="display:none;" class="error-message">Моля изберете категория</div>';

        echo '<div id="levelOneCategoriesDiv" style="padding: 0; margin: 0;"></div>';
        echo '<div id="levelOneCategoriesJsErrorMsg1" style="display:none;" class="error-message">Моля изберете субкатегория</div>';

        echo '<div id="levelTwoCategoriesDiv" style="padding: 0; margin: 0;"></div>';
        echo '<div id="levelTwoCategoriesJsErrorMsg1" style="display:none;" class="error-message">Моля изберете субкатегория</div>';

        echo '<div id="levelThreeCategoriesDiv" style="padding: 0; margin: 0;"></div>';
        echo '<div id="levelThreeCategoriesJsErrorMsg1" style="display:none;" class="error-message">Моля изберете субкатегория</div>';

        echo '<div id="levelFourCategoriesDiv" style="padding: 0; margin: 0;"></div>';
        echo '<div id="levelFourCategoriesJsErrorMsg1" style="display:none;" class="error-message">Моля изберете субкатегория</div>';

        echo '<div id="levelInfinityCategoriesDiv" style="padding: 0; margin: 0;"></div>';
        echo '<div id="levelNCategoriesJsErrorMsg1" style="display:none;" class="error-message">Моля изберете субкатегория</div>';

        echo $this->Form->input(
                'title', array(
            'label' => 'Заглавие: <br /><span style="font-size: small; font-family: arial,helvetica,sans-serif; color: #262626;">Това поле е само за името на фирмата или сайта ви.</span>',
            'error' => false
                )
        );
        echo $this->Form->error(
                'title', array(
            'TitleRule1' => 'Полето "Заглавие" е задължително.',
            'TitleRule2' => 'Полето "Заглавие" е задължително.'
                ), array(
            'wrap' => 'div',
            'class' => 'error-message'
                )
        );
        echo '<div id="ListingTitleJsErrorMsg1" style="display:none;" class="error-message">Полето "Заглавие" е задължително</div>';

        echo $this->Form->input(
                'description', array(
            'label' => 'Описание: <br /><span style="font-size: small; font-family: arial,helvetica,sans-serif; color: #262626;">Напишете уникално описание(не копирайте текст от интернет),не по-късо от 30 думи.</span>',
            'error' => false
                )
        );
        echo '<div id="ListingDescriptionJsErrorMsg1" style="display:none;" class="error-message">Полето "Описание" е задължително.</div>';
        echo '<div id="ListingDescriptionJsErrorMsg2" style="display:none;" class="error-message">Описанието трябва да бъде поне от 30 думи!</div>';

        echo $this->Form->error(
                'description', array(
            'DescriptionRule1' => 'Полето "Описание" е задължително.',
            'DescriptionRule2' => 'Полето "Описание" е задължително.',
            'DescriptionRule3' => 'Описанието трябва да бъде поне от 30 думи!'
                ), array(
            'wrap' => 'div',
            'class' => 'error-message'
                )
        );

        echo $this->Form->input(
                'url', array(
            'label' => 'Уеб адрес: <br /><span style="font-size: small; font-family: arial,helvetica,sans-serif; color: #262626;">Поставете уеб адреса на фирмата тук.Трябва да започва с : " http:// "</span>',
            'error' => false
                )
        );

        echo $this->Form->input(
                'email', array(
            'label' => 'Email',
            'error' => false
                )
        );

        echo $this->Form->input(
                'landline', array(
            'label' => 'Телефон:',
            'error' => false
                )
        );

        echo $this->Form->input(
                'mobile', array(
            'label' => 'Мобилен телефон:',
            'error' => false
                )
        );

        echo $this->Form->input(
                'postcode', array(
            'label' => 'Пощенски код:',
            'error' => false
                )
        );

        echo $this->Form->input(
                'address_1', array(
            'label' => 'Адрес: <br /><span style="font-size: small; font-family: arial,helvetica,sans-serif; color: #262626;">Напишете пълния адрес на фирмата ви за да може да я изобразим на карта.Ако добавяте сайт,който няма физически адрес,напишете просто: "Интернет"</span>',
            'error' => false
                )
        );

        echo $this->Form->input(
                'address_2', array(
            'label' => '',
            'error' => false
                )
        );
        echo '<input type="hidden" id="train_stations" name="data[Listing][train_stations]" value=""/>';
        echo '<input type="hidden" id="bus_stations" name="data[Listing][bus_stations]" value=""/>';
        echo '<input type="hidden" id="subway_stations" name="data[Listing][subway_stations]" value=""/>';

        //echo '<input id="searchTextField" type="text" style=" width:98%;height:30px; font-size:small;" placeholder=""/>';
        echo '<input type="button" onclick="findonmap()" value="Find On Map" style="width:30% !important"/>';
        echo '<div id="map_canvas2" style="height:200px; width:98%"></div>';
        echo $this->Form->input(
                'tags_text', array(
            'type' => 'textarea',
            'label' => 'Ключови думи: <br /><span style="font-size: small; font-family: arial,helvetica,sans-serif; color: #262626;">Напишете ключови думи,които описват вашите продукти или услуги,разделени със запетая.Пример: Цетарски магазин ,Безплатна доставка, Ниски цени, ...</span>',
            'error' => false
                )
        );


		echo "<div id='oprningHOurDIV' ><div id='oprningHOur' >Opening Hours";
		echo $this->Form->input(
		'opening_day', array(
                                'name' => 'data[Listing][opening_day][]',
				'label' => false,
				'empty' => '(select Day)',
				'options' => array('Every day', 'Weekdays', 'Weekends', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'),
				'error' => false,
				'div' => false,
				'style' => 'width:100px;'
				)
		);
		$hours = array();
		for($i=1; $i<25; $i++){
                    if($i < 10) {
			$hours[$i] = '0'.$i.':00';
                    } else {
                        $hours[$i] = $i.':00';
                    }
		}

		echo $this->Form->input(
				'opening_hour_start', array(
                                                'name' => 'data[Listing][opening_hour_start][]',
						'label' => false,
						'empty' => '(select Start Hour)',
						'options' => $hours,
						'error' => false,
						'div' => false,
						'style' => 'width:100px;'
				)
		);
		echo $this->Form->input(
				'opening_hour_end', array(
                                                'name' => 'data[Listing][opening_hour_end][]',
						'label' => false,
						'empty' => '(select End Hour)',
						'options' => $hours,
						'error' => false,
						'div' => false,
						'style' => 'width:100px;'
				)
		); ?>
        </div>
        <a href="javascript:void(0)" onClick="addNewOpeningHours();" >Add another set of hours</a>
                </div>

<script>
function addNewOpeningHours() {
        var rtext = "";
	var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	for( var i=0; i < 15; i++ ) {
	    rtext += possible.charAt(Math.floor(Math.random() * possible.length));
	}
        var HTML = $("#oprningHOur").html();
        $("#oprningHOurDIV").append("<div id='"+rtext+"'>"+HTML+"<a href='javascript:void(0)' onClick='removeOpeningHours(\""+rtext+"\");' >Remove</a></div>");
}
function removeOpeningHours( divID){
    $("#"+divID).remove();
}
function addNewPhotoControl() {
        var rtext = "";
	var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	for( var i=0; i < 15; i++ ) {
	    rtext += possible.charAt(Math.floor(Math.random() * possible.length));
	}
        var HTML = $("#firstPhotoControl").html();
        $("#photoControl").append("<div id='"+rtext+"'>"+HTML+"<a href='javascript:void(0)' onClick='removeOpeningHours(\""+rtext+"\");' >Remove</a></div>");
       
}

</script>
	<?php	$options_list = array('Cash','Cheques', 'Direct Debit', 'Credit Cards', 'PayPal', 'Bank Transfers', 'Skrill');
		echo $this->Form->input('payment_method', array(
						'label' => 'Payment Method',
						'type' => 'select',
						'multiple' => 'checkbox',
						'options' => $options_list,
						'selected' => $this->data['Listing']['payment_method'],
				)
		);
		$options_list = array('Children', 'Groups', 'Families', 'Dates', 'Disabled People', 'Business Meetings', 'Birthdays','Parties');
		echo $this->Form->input('good_for',array(
						'label' => 'Good For',
						'type' => 'select',
						'multiple' => 'checkbox',
						'options' => $options_list,
							'selected' => $this->data['Listing']['good_for'],
				)
		);
		$options_list = array('Free Parking', 'Paid Parking', 'Disability Access');
		echo $this->Form->input('access',array(
						'type' => 'select',
						'multiple' => 'checkbox',
						'options' => $options_list,
						'selected' => $this->data['Listing']['access'],
				)
		);


		$years = array();
		for($i = 1900; $i< 2014; $i++){
			$years[$i] =  $i;
		}
		echo $this->Form->input(
		'year_established', array(
				'label' => 'Year Established',
				'empty' => '(select Year)',
				'options' => $years,
				'error' => false,
				'div' => false
				)
		);

		echo $this->Form->input('number_of_employee', array('empty'=>'Select', 'options'=>array('1-5', '5-10', '10-20', '20-50', '50-100', 'over 100')));

		echo $this->Form->input('video', array('label'=>'Video Upload(You have to add the link of video uploaded on YouTube)'));

		echo $this->Form->file('image', array('label'=>'Photo Upload Max File size is 700KB'));

        ?>
    </fieldset>
        <?php
        echo $this->Form->end(
                array(
                    'label' => 'Добави сайт',
                    'id' => 'btn__add___Submit'
                )
        );
        ?>
</div>
<?php } ?>